package com.hb.core.enums;

import org.apache.catalina.User;

/**
 * @description: 用户状态
 * @projectName: zhb-frame-build
 * @author: zhouhaizhi
 * @createTime: 2021/9/2 10:31
 * @version:1.0
 */
public enum UserStatus {

    disable(0, "禁用"),
    enable(1, "启用");

    private Integer code;

    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    UserStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static UserStatus getUserStatusByCode(Integer code) {
        UserStatus[] arr = UserStatus.values();
        for (UserStatus userStatus : arr) {
            if (userStatus.getCode().equals(code)) {
                return userStatus;
            }
        }
        return null;
    }

    public static String getNameByCode(Integer code){
        UserStatus userStatus = getUserStatusByCode(code);
        if (null != userStatus) {
            return userStatus.getName();
        }
        return null;
    }

}
